var ctx;
var firstLevel = 1;
var secondLevel = 2;
var firstCategory = '';
var secondCategory = '';

function setCtx(ctx) {
    this.ctx = ctx;
}
var targetTab;
var attrNames = new Array();
var initCol = 3;

$(function(){
	initListener();  //添加区域监听事件
	
	targetTab =  $('#goodsInfo_li');
	
	var firstRow = $('#attr_spec tr:eq(0) td');
	var flag = firstRow.length - initCol;
	$('#attr_spec tr:eq(0)').find('td').each(function(index){
        if(flag > 0 && index < flag){
            attrNames.push($(this).text());
        }
    });
});

//省市区级联
function initListener() {
    $("#firstCategory").change(function () {
        firstCategory = $('#firstCategory').val();
        if (firstCategory != '') {
            $.ajax({
                type : "GET",
                url : ctx + "/goodsCategory/getCategoryByParentId",
                cache : false,
                dataType : 'json',
                data : {
                    parentId : firstCategory
                },
                success : function(data) {
                    if (data.success) {
                        var result = "<option value='" + "'>--二级分类--</option>";
                        $.each(data.obj, function(index, item) {
                            result += "<option id='" + item.name + "'" + " value='" + item.id + "'>" + item.name + "</option>";
                        });
                        $("#secondCategory").html('');
                        $("#secondCategory").append(result);
                    }
                }
            });
        } else {
            var result = "<option value='" + "'>--二级分类--</option>";
            $("#secondCategory").html('');
            $("#secondCategory").append(result);
        }
    });
    
    $('#secondCategory').change(function() {
        if ($('#secondCategory').val() != 0) {
            secondCategory = $('#secondCategory').val();
            if(secondCategory != ''){
                $.ajax({
                    type : "POST",
                    url : ctx + "/goodsInfo/getGoodsAttrByCategoryId",
                    cache : false,
                    dataType : 'json',
                    data : {
                        categoryId : secondCategory
                    },
                    success : function(data) {
                        if (data.success) {
                              var jsonObj=eval("("+data.obj+")");  
                              
                              var html = "<table style='width:100%; margin-top:0px;table-layout:fixed'><tbody><tr>";
                                $.each(jsonObj, function (i, item) {
                                    html += "<input id='attrId"+item.id+"' type='hidden' value="+item.id+" >";
                                    html += "<th width='10%' style='background-color: #e0eff3;height:40px'>"+item.name+"</th>";
                                });
                                html += "<tr></tbody>";
                                html += "<tbody id='tableTbody'>";
                                html += "<tr>";
                                    $.each(jsonObj, function (i, item) {
                                        if(item.inputType == 1){
                                            html += "<td><select class='editform-control' style='height: 31px;'>";
                                            for(var j = 0;j < item.categoryAttrValues.length;j++){
                                                    html += "<option value="+item.categoryAttrValues[j].id+">"+item.categoryAttrValues[j].name+"</option>";
                                                    
                                            }
                                            html += "</select></td>";
                                        }else if(item.inputType == 2){
                                            html += "<td><input class='controlEdit' type='text' maxlength='50' value='11' ></td>";
                                        }
                                    });
                                html += "</tr>";
                                html += "</tbody></table>";
                                $("#goodsSpecification").append(html);
                        }
                    }
                });
            }
        }
    });

}

// 检测商品信息输入栏
function checkGoogsInfoInput(){
	var goodsType = $("#type").val();
	return checkLogo() && checkGoodsName() && checkFirstCategory() && checkSecondCategory() && checkMarketPrice() && checkUnit() && checkRecommendLevel() && checkSort() && checkImg() && checkStockAmount()
		&& ((goodsType = 1 && checkBusinessPrice()) || (goodsType = 2 && checkIntegralPrice()) || 
	    (goodsType = 3 && checkSecKillPrice() && checkStartDate() && checkStartTime() && checkEndDate() && checkEndTime()));
}


function gotoGoodsInfo(target){
    var goodsType = $("#type").val();
    $("#goodsInfo")[0].style.display="block";
    $("#goodsDescrip")[0].style.display="none";
    $("#goodsSpec")[0].style.display="none";
    
    $(targetTab).removeClass('tabhover');
    $(target).addClass('tabhover');
    targetTab = target;
}

function gotoGoodsDescrip(target){
    var flag = true;
    if($('#goodsInfo').is(':visible')){
        flag = checkGoogsInfoInput();
    }
    if(flag){
        $("#goodsDescrip")[0].style.display="block";
        $("#goodsInfo")[0].style.display="none";
        $("#goodsSpec")[0].style.display="none";
        
        $(targetTab).removeClass('tabhover');
        $(target).addClass('tabhover');
        targetTab = target;
    }
}

function gotoGoodsSpec(target){
    var flag = true;
    if($('#goodsInfo').is(':visible')){
    	flag = checkGoogsInfoInput();
    }
    if(flag) {
    	$("#goodsSpec")[0].style.display="block";
    	$("#goodsDescrip")[0].style.display="none";
    	$("#goodsInfo")[0].style.display="none";
    	
    	$(targetTab).removeClass('tabhover');
    	$(target).addClass('tabhover');
    	targetTab = target;
    }
}

//验证商品logo不能为空
function checkLogo(){
	var imageLogoUrl = $('#imageLogo').val();
	if(imageLogoUrl == null || imageLogoUrl == ""){
		layer.msg("请上传封面图片！",{
          icon: 3,
          time: 2000 //2秒关闭（如果不配置，默认是3秒）
      });
		return false;
	}else{
		return true;
	}
}

//验证商品名
function checkGoodsName(){
    var goodsName = $("#goodsName").val();
    //解决ie9以下placeholder与value重复的问题
    if(goodsName == $("#goodsName").attr("placeholder")){
        goodsName = "";
    }
    if(goodsName == null || goodsName == ""){
        layer.tips('商品名不能为空!', '#goodsName', {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//验证商品一级分类
function checkFirstCategory(){
    var firstCategory = $("#firstCategory").val();
    if(firstCategory == null || firstCategory == ""){
        layer.tips('商品一级分类不能为空!', '#firstCategory', {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//验证商品二级分类
function checkSecondCategory(){
  var secondCategory = $("#secondCategory").val();
  if(secondCategory == null || secondCategory == ""){
      layer.tips('商品二级分类不能为空!', '#secondCategory', {
          tips: 3,
          time:1000
      });
      return false;
  }else{
      return true;
  }
}

//验证商品库存
function checkStockAmount(){
    var goodsType = $('#type').val();
    var stockAmount = $("#stockAmount").val();
    //解决ie9以下placeholder与value重复的问题
    if(stockAmount == $("#stockAmount").attr("placeholder")){
        stockAmount = "";
    }
    if(stockAmount == null || stockAmount == ""){
        layer.tips('商品库存不能为空!', '#stockAmount', {
            tips: 3,
            time:1000
        });
        return false;
    }else if(parseInt(stockAmount) < 0){
        layer.tips('请输入正数!', '#stockAmount', {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//验证商品价格
function checkBusinessPrice(){
    var goodsType = $('#type').val();
    var businessPrice = $("#businessPrice").val();
    //解决ie9以下placeholder与value重复的问题
    if(businessPrice == $("#businessPrice").attr("placeholder")){
        businessPrice = "";
    }
    if(goodsType == 1){
        if(businessPrice == null || businessPrice == ""){
            layer.tips('商品价格不能为空!', '#businessPrice', {
                tips: 3,
                time:1000
            });
            return false;
        }else if(parseInt(businessPrice) < 0){
            layer.tips('请输入正数!', '#businessPrice', {
                tips: 3,
                time:1000
            });
            return false;
        }else{
            return true;
        }
    }
}

//验证兑换积分
function checkIntegralPrice(){
    var reg = /^[0-9]*[1-9][0-9]*$/;
    var goodsType = $('#type').val();
    var integralPrice = $("#integralPrice").val();
    //解决ie9以下placeholder与value重复的问题
    if(integralPrice == $("#integralPrice").attr("placeholder")){
        integralPrice = "";
    }
    if(goodsType == 2){
        if(integralPrice == null || integralPrice == ""){
            layer.tips('兑换积分不能为空!', '#integralPrice', {
                tips: 3,
                time:1000
            });
            return false;
        }else if(!reg.test(integralPrice)){
            layer.tips('请输入正整数!', '#integralPrice', {
                tips: 3,
                time:1000
            });
            return false;
        }else{
            return true;
        }
    }
}

//验证秒杀商品价格
function checkSecKillPrice(){
    var goodsType = $('#type').val();
    var secKillPrice = $("#secKillPrice").val();
    //解决ie9以下placeholder与value重复的问题
    if(secKillPrice == $("#secKillPrice").attr("placeholder")){
        secKillPrice = "";
    }
    if(goodsType == 3){
        if(secKillPrice == null || secKillPrice == ""){
            layer.tips('商品价格不能为空!', '#secKillPrice', {
                tips: 3,
                time:1000
            });
            return false;
        }else if(parseInt(secKillPrice) < 0){
            layer.tips('请输入正数!', '#secKillPrice', {
                tips: 3,
                time:1000
            });
            return false;
        }else{
            return true;
        }
    }
}

//验证市场价格
function checkMarketPrice(){
    var marketPrice = $("#marketPrice").val();
    //解决ie9以下placeholder与value重复的问题
    if(marketPrice == $("#marketPrice").attr("placeholder")){
        marketPrice = "";
    }
    if(marketPrice == null || marketPrice == ""){
        return true;
    }else if(parseInt(marketPrice) < 0){
        layer.tips('请输入正数!', '#marketPrice', {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//验证商品单位
function checkUnit(){
  var unit = $("#unit").val();
  //解决ie9以下placeholder与value重复的问题
  if(unit == $("#unit").attr("placeholder")){
	  unit = "";
  }
  if(unit == null || unit == ""){
      layer.tips('商品单位不能为空!', '#unit', {
          tips: 3,
          time:1000
      });
      return false;
  }else{
      return true;
  }
}

//验证推荐等级
function checkRecommendLevel(){
    var reg = /^[0-9]*[1-9][0-9]*$/;
    var recommendLevel = $("#recommendLevel").val();
    if(recommendLevel == null || recommendLevel == ""){
        return true;
    }else if(!reg.test(recommendLevel)){
        layer.tips('请输入正整数!', '#recommendLevel', {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//验证秒杀开始日期
function checkStartDate(){
    var goodsType = $('#type').val();
    var startDate = $("#startDate").val();
    //解决ie9以下placeholder与value重复的问题
    if(startDate == $("#startDate").attr("placeholder")){
        startDate = "";
    }
    
    var start = new Date(startDate.replace("-", "/").replace("-", "/"));
    if(goodsType == 3){
        if(startDate == null || startDate == ""){
            layer.tips('秒杀开始日期不能为空!', '#startDate', {
                tips: 3
            });
            return false;
        }else{
            return true;        
        }
    }
}

//验证秒杀开始时间
function checkStartTime(){
    var goodsType = $('#type').val();
    var startTime = $("#startTime").val();
    //解决ie9以下placeholder与value重复的问题
    if(startTime == $("#startTime").attr("placeholder")){
        startTime = "";
    }
    
    var start = new Date(startTime.replace("-", "/").replace("-", "/"));
    if(goodsType == 3){
        if(startTime == null || startTime == ""){
            layer.tips('秒杀开始时间不能为空!', '#startTime', {
                tips: 3
            });
            return false;
        }else{
            return true;        
        }
    }
}

//验证秒杀结束日期
function checkEndDate(){
    var goodsType = $('#type').val();
    var endDate = $("#endDate").val();
    //解决ie9以下placeholder与value重复的问题
    if(endDate == $("#endDate").attr("placeholder")){
        endDate = "";
    }
    if(goodsType == 3){
        if(endDate == null || endDate == ""){
            layer.tips('秒杀结束日期不能为空!', '#endDate', {
                tips: 3,
                time:1000
            });
            return false;
        }else {
            return true;
        }
    }
}

//验证秒杀结束时间
function checkEndTime(){
    var goodsType = $('#type').val();
    var startDate = $("#startDate").val();
    var startTime = $("#startTime").val();
    //解决ie9以下placeholder与value重复的问题
    if(startDate == $("#startDate").attr("placeholder")){
        startDate = "";
    }
    if(startTime == $("#startTime").attr("placeholder")){
        startTime = "";
    }
    var start = new Date(startDate + " " +startTime); 
    var endDate = $("#endDate").val();
    var endTime = $("#endTime").val();
    //解决ie9以下placeholder与value重复的问题
    if(endDate == $("#endDate").attr("placeholder")){
    	endDate = "";
    }
    if(endTime == $("#endTime").attr("placeholder")){
    	endTime = "";
    }
    var end = new Date(endDate + " " +endTime); 
    if(goodsType == 3){
        if(endTime == null || endTime == ""){
            layer.tips('秒杀结束时间不能为空!', '#endTime', {
                tips: 3,
                time:1000
            });
            return false;
        }else if(end < start){
            layer.msg("秒杀结束时间应大于起始时间",{
                icon: 3,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }else{
            return true;
        }
    }
}

//验证排序不能为空
function checkSort(){
    var reg = /^[0-9]*[1-9][0-9]*$/;
    var sort = $("#sort").val();
    if(sort == null || sort == ""){
        layer.tips('排序不能为空!', '#sort', {
            tips: 3,
            time:1000
        });
        return false;
    }else if(!reg.test(sort)){
        layer.tips('请输入正整数!', '#sort', {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//验证商品图片不能为空
function checkImg(){
	var length = $("#imgLength").val();
	if(length > 0){
		return true;
	}else{
		layer.msg("请至少上传一张商品图片！",{
          icon: 3,
          time: 2000 //2秒关闭（如果不配置，默认是3秒）
		});
		return false;
	}
}

// 检验新增规格输入
function checkInputSpec(){
    var firstRow = $('#attr_spec tr:eq(0) td');
    var realClo = firstRow.length;
    var specs = new Array();
    $('#attr_spec').find('tr:not(:first)').each(function(){
        $(this).find('td input').each(function(index){
            var flag = firstRow.length - initCol;
            if(flag > 0 && index < flag){
                switch (index) {
                case 0:
                    if(!checkInput(this,'请输入属性名称')){
                        $('#this').focus();
                        return false;
                    }
                    break;
                case 1:
                    if(!checkInput(this,'请输入属性名称')){
                        $('#this').focus();
                        return false;
                    }
                    break;
                case 2:
                    if(!checkInput(this,'请输入属性名称')){
                        $('#this').focus();
                        return false;
                    }
                    break;
                default:
                    break;
                }
            }
        });
        var target = $(this).find('input[name="price"]');
        if(!checkInput(target,'请输入价格')){
            $(target).focus();
            return false;
        }
        target = $(this).find('input[name="stock"]');
        if(!checkInput(target,'请输入库存')){
            $(target).focus();
            return false;
        }
    });
}
//保存或新增方法
function saveGoodsInfo() {
    checkInputSpec();
    var infoList = getSpecValues();
    var goodsType = $('#type').val();
    
    if(checkLogo() && checkGoodsName() && checkFirstCategory() && checkSecondCategory() && checkMarketPrice() && checkUnit() && checkRecommendLevel() && checkSort() && checkImg() && checkStockAmount() &&
            (goodsType == 1 && checkBusinessPrice()) || (goodsType == 2 && checkIntegralPrice()) || 
            (goodsType == 3 && checkSecKillPrice() && checkStartDate() && checkStartTime() && checkEndDate() && checkEndTime())){
	    	var index1 = layer.load(1);
            $.ajax({
                type : "POST",
                url : ctx + "/goodsInfo/saveOrUpdateGoodsInfo",
                cache : false,
                dataType : 'json',
                contentType : 'application/json;charset=utf-8', //设置请求头信息
                data:JSON.stringify(infoList),
                success : function(result) {
                    if (result.success) {
                        layer.msg("操作成功",{
                            icon: 1,
                            time: 3000 //2秒关闭（如果不配置，默认是3秒）
                        },function(){
                            loadContent("/goodsInfo/goodsInfoList?goodsType=" + result.obj.type);
                        });
                    } else {
    					layer.close(index1);
                        layer.msg("操作失败",{
                            icon: 2
                        });
                    }
                }
            });
    }
}

function showDefineAttr(){
    $("#defineAttr").toggle();
}

function hideDefineAttr(){
    $("#defineAttr").hide();
}

// 只能输入数字、两位小数
function checInputNum(obj) {
    obj.value=(obj.value.match(/\d+(\.\d{0,2})?/)||[''])[0];
}

//只能输入数字
function checInputNumOnly(obj) {
    obj.value=obj.value.replace(/[^\d]/g,'');
}


function checkInput(target, tip){
    var value = $(target).val();
    //解决ie9以下placeholder与value重复的问题
    if(value == $(target).attr("placeholder")){
        value = "";
    }
    if(value == null || value == ""){
        layer.tips(tip, target, {
            tips: 3,
            time:1000
        });
        return false;
    }else{
        return true;
    }
}

//返回上一页
function cancel(){
    var goodsType = $("#type").val();
    loadContent("/goodsInfo/goodsInfoList?goodsType=" + goodsType);
}

// 添加行
function appendRow(){
	if(attrNames.length == 0) {
		layer.msg("请先添加自定义属性",{
            icon: 2,
            time: 1000
        });
        return;
	}
	var goodsType = $('#type').val();
	
    var firstRow = $('#attr_spec tr:eq(0)');
    var appendTd = '';
    if(firstRow.length == 0 ) {
        appendTd += '<td><input type="text" class="add-input"></td>'+
            '<td><input type="text" class="add-input" ></td>';
    } else {
        var firstRowTds = $('#attr_spec tr:eq(0) td');
        for(var i = 0; i < firstRowTds.length; i++) {
            if( i == firstRowTds.length - 1) {
                appendTd += '<td><input type="button" value="删除" onclick="deleteRow(this);" class="delete-btn"/></td>';
            } else if(i == firstRowTds.length - 2) {
                appendTd += '<td><input type="text" name="stock" onkeyup="checInputNumOnly(this)" class="add-input"/></td>';
            } else if(i == firstRowTds.length - 3) {
            	if(2 == goodsType) {
                    appendTd += '<td><input type="text" name="price" onkeyup="checInputNumOnly(this)" class="add-input"/></td>';
                } else {
                    appendTd += '<td><input type="text" name="price" onkeyup="checInputNum(this)" class="add-input"/></td>';
                }
            } else {
                appendTd += '<td><input type="text"  class="add-input"></td>';
            }
        }
    }
    $('#attr_spec').append('<tr>' + appendTd + '</tr>');
}


function appendCloumn(){
    if($('#attr_spec').is(':hidden')){
        $('#attr_spec').show();
    }
//    $("#attr_spec tr:eq(0)").before('<tr><td><input type="text" style="width:80px;"></td></tr>');
    var attrName = $('#attr_name').val();
    if('' == attrName) {
        return;
    }
    if(attrNames.length >= 3) {
        layer.msg("属性达到上限",{
            icon: 2,
            time: 1000
        });
        return;
    }
    if($.inArray(attrName, attrNames) != -1) {
        layer.msg("属性名称已存在",{
            icon: 2,
            time: 1000
        });
        return;
    }
    
    $('#attr_spec').find('tr').each(function(index){
        if(index == 0) {
            attrNames.push(attrName);
            $(this).prepend('<td class="bg-td" width="250px">'  + attrName + "<img id='close' src='images/guanbi.png' onclick='delete_cloum(this);' >" + '</td>');
        } else {
            $(this).prepend('<td ><input type="text" class="add-input"></td>');
        }
    });
}

function delete_cloum(target){
    var current_td=$(target).parent();
    var attrName = $(current_td).text();
    var index=current_td.index();
    $('#attr_spec').find('tr').each(function(){
        $(this).children().eq(index).remove();
    })
    attrNames.remove(attrName);
    if(attrNames.length == 0) {
    	$('#attr_spec').find('tr:not(:first)').each(function(index){
    		$(this).remove();
    	});
    }
}

function deleteRow(target){
    $(target).parent().parents('tr').remove();
}


function getSpecValues(){
    
    var goodsType = $('#type').val();
    if($('#goodsId').val() != "" && $('#goodsId').val() != undefined){
        var goodsId = $('#goodsId').val();
    }else{
        var goodsId = 0;
    }
    var imageLogoUrl = $('#imageLogo').val();
    var goodsName = $('#goodsName').val();
    var secondCategory = $('#secondCategory').val();
    var marketPrice = $("#marketPrice").val();
    var unit = $("#unit").val();
    var keyword = $("#keyword").val();
    var isRecommend = $("#recommendLevel").val();
    var sort = $('#sort').val();
    var container = ue.getContent();
    var stockAmount = $("#stockAmount").val();

    //解决ie9以下placeholder与value重复的问题
    if(goodsName == $("#goodsName").attr("placeholder")){
        goodsName = "";
    }
    if(keyword == $("#keyword").attr("placeholder")){
        keyword = "";
    }
    var keywordString = keyword.replace('，',',');//转换为英文逗号隔开的字符串 
    var length = $("#imgLength").val();
    var imgArr = [];
    for(var i=1;i <= length;i++){
        if($("#imgId" + i).val() != null){
            imgArr.push($("#imgId" + i).val());
        }
    }
    var price;
    var integralNum;
    var startDate;
    var startTime;
    var endDate;
    var endTime;
    var start;
    var end;
    var startDT;
    var endDT;
    if(goodsType == 1){
        price = $('#businessPrice').val();
        if(price == $("#businessPrice").attr("placeholder")){
            price = "";
        }
    }
    if(goodsType == 2){
        integralNum = $('#integralPrice').val();
        if(integralNum == $("#integralPrice").attr("placeholder")){
            integralNum = "";
        }
    }
    if(goodsType == 3){
        price = $('#secKillPrice').val();
        if(price == $("#secKillPrice").attr("placeholder")){
            price = "";
        }
        
        startDate = $("#startDate").val();
        startTime = $("#startTime").val();
        //解决ie9以下placeholder与value重复的问题
        if(startDate == $("#startDate").attr("placeholder")){
            startDate = "";
        }
        if(startTime == $("#startTime").attr("placeholder")){
            startTime = "";
        }
        start = startDate + " " +startTime;
        startDT = new Date(start); 
        
        endDate = $("#endDate").val();
        endTime = $("#endTime").val();
        //解决ie9以下placeholder与value重复的问题
        if(endDate == $("#endDate").attr("placeholder")){
        	endDate = "";
        }
        if(endTime == $("#endTime").attr("placeholder")){
        	endTime = "";
        }
        end = endDate + " " +endTime;
        endDT = new Date(end); 
    }
    
    var firstRow = $('#attr_spec tr:eq(0) td');
    var initCol = 3;
    var realClo = firstRow.length;
    
    var specs = new Array();
    
    $('#attr_spec').find('tr:not(:first)').each(function(){
    	
    	var info = {};
        info.goodsName = goodsName;
        info.secondCategory = secondCategory;
        info.goodsType = goodsType;
        info.price = price;
        info.stockAmount = stockAmount;
        info.integralNum = integralNum;
        info.marketPrice = marketPrice;
        info.unit = unit;
        info.keyword = keywordString;
        info.isRecommend = isRecommend;
        info.sort = sort;
        info.goodsId = goodsId;
        info.container = container;
        info.startTime = start;
        info.endTime = end;
        info.imageLogoUrl = imageLogoUrl;
        info.imgArr = imgArr;
        
//    $('#attr_spec').find('tr').each(function(rowIndex){
        $(this).find('td input').each(function(index){
            var flag = firstRow.length - initCol;
            if(flag > 0 && index < flag){
                switch (index) {
                case 0:
                    info.attr1 = attrNames[0]
                    info.attr1Value = this.value;
                    break;
                case 1:
                    info.attr2 = attrNames[1]
                    info.attr2Value = this.value
                    break;
                case 2:
                    info.attr3 = attrNames[2]
                    info.attr3Value = this.value
                    break;
                default:
                    break;
                }
            }
        });
        info.price = $(this).find('input[name="price"]').val();
        info.stock = $(this).find('input[name="stock"]').val();
        info.specId = $(this).find('input[name="specId"]').val();
        specs.push(info);
    });
    if(specs.length == 0) {
    	var info = {};
        info.goodsName = goodsName;
        info.secondCategory = secondCategory;
        info.goodsType = goodsType;
        info.price = price;
        info.stockAmount = stockAmount;
        info.integralNum = integralNum;
        info.marketPrice = marketPrice;
        info.unit = unit;
        info.keyword = keywordString;
        info.isRecommend = isRecommend;
        info.sort = sort;
        info.goodsId = goodsId;
        info.container = container;
        info.startTime = start;
        info.endTime = end;
        info.imageLogoUrl = imageLogoUrl;
        info.imgArr = imgArr;
        
        specs.push(info);
    }
    return specs;
}

function showdelete(target){
    $(target).children("span").css("display","block");
}

function hidedelete(target){
    $(target).children("span").css("display","none");
}
